const fs=require('fs');
const https=require('https'); 
//获取高分纪录片top20
const getDouban=function(){
    const category='纪录片'
    const req = https.get(`https://movie.douban.com/j/new_search_subjects?sort=S&range=0,100&tags=${encodeURI(category)}&start=0`, (res) => {
            res.setEncoding('utf8');  
            let Data=''
            res.on('data', (d) => {
                Data += d;
            }).on('end',()=>{
                fs.writeFile(`./douban.json`,Data,  res=> {
                console.log('douban.json生成成功')
                });
            })
        });
    req.on('error', (e) => {
        console.error(e);
    })

    req.end();
} 

getDouban();